﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace EFCodeFirstTest
{
    using System.Data.Entity;
    using System.ComponentModel.DataAnnotations;

    /// <summary>
/// Department class
/// </summary>
public class Department
{
    [Key] //To make it Primary Key and Identity
    public int DeptId { get; set; }
    public string DeptName { get; set; }

    //Create Employee navigation property for Lazy Loading (1:many)
    public virtual ICollection<Employee> Employees { get; set; }
}

/// <summary>
/// Employee class
/// </summary>
public class Employee
{
    [Key] //To make it Primary Key and Identity
    public int EmpId { get; set; }
    public string FirstName { get; set; }
    public string LastName { get; set; }
    public int DeptId { get; set; }

    //Create Department navigation property for Lazy Loading
    public virtual Department Department { get; set; }
}
//After that you need the context class to create the connection

public class EmpDeptContext : DbContext
{
    public DbSet<Employee> Emps { get; set; }
    public DbSet<Department> Depts { get; set; }
}
//After that you write your application to add Departments and Employees and this will automatically create a database first at you localhost\sqlexpress (if no option provided), then enter the data into it.




}
